package com.city.itis.interceptor;

import java.util.Map;

import com.opensymphony.xwork2.Action;
import com.opensymphony.xwork2.ActionContext;
import com.opensymphony.xwork2.ActionInvocation;
import com.opensymphony.xwork2.interceptor.Interceptor;

/**
 * 拦截用户是否登陆Interceptor
 * @author WY
 *
 */
public class UserLoginInterceptor implements Interceptor
{

	private static final long serialVersionUID = 1L;

	@Override
	public void destroy() 
	{
		// TODO Auto-generated method stub

	}

	@Override
	public void init() 
	{
		// TODO Auto-generated method stub

	}

	@Override
	public String intercept(ActionInvocation invocation) throws Exception 
	{
		Map<String,Object> session=ActionContext.getContext().getSession();
		if(session!=null)
		{
			Object user=session.get("login_user");
			if(user!=null)
			{
				return invocation.invoke();
			}else
			{
				return Action.LOGIN;
			}
		}
		
		return Action.LOGIN;
	}

}
